package com.supermap.dataservice.cloud.agrinfo;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.cloud.agrinfo.AgrinfoCloudService;
import javax.annotation.Resource;

/**
 * @author aqua
 * @description
 * @date 2018年11月16 上午 10:52
 * @email 1301584033@qq.com
 */
@Service
public class AgrinfoCloudServiceImpl implements AgrinfoCloudService {

    @Resource
    private AgrinfoCloudMapper agrinfoCloudMapper;
    @Override
    public JSONUtil getAgrinfoByareaCodeAndbreed(String areaCode, String cropBreedId) {

        return new JSONUtil().setData(agrinfoCloudMapper.getAgrinfoByareaCodeAndbreed(areaCode,cropBreedId));
    }

    @Override
    public JSONUtil getAgrinfoDetailsByUserId(String userId,Integer pageNum,Integer pageSize) {
        pageNum=(pageNum-1)*pageSize;
        return new JSONUtil().setData(agrinfoCloudMapper.
                getAgrinfoDetailsByUserId(userId,pageNum,pageSize)).
                setCountSum(agrinfoCloudMapper.getAgrinfoDetailsByUserIdByCount(userId));
    }

    @Override
    public JSONUtil getDisasterByareaCodeAndbreed(String areaCode, String cropBreedId, String disatype) {
        return new JSONUtil().setData(agrinfoCloudMapper.getDisasterByareaCodeAndbreed(areaCode,cropBreedId,disatype));
    }

    @Override
    public JSONUtil getDisasterDetailsByUserId(String userId, Integer pageNum, Integer pageSize) {
        pageNum=(pageNum-1)*pageSize;
        return new JSONUtil().setData(agrinfoCloudMapper.
                getPageDisasterListByUserID(userId,pageNum,pageSize)).
                setCountSum(agrinfoCloudMapper.getPageDisasterListByUserIDCount(userId));
    }

    @Override
    public JSONUtil getFarmingByareaCodeAndbreed(String areaCode, String cropBreedId) {
        return new JSONUtil().setData(agrinfoCloudMapper.getFarmingByareaCodeAndbreed(areaCode,cropBreedId));
    }

    @Override
    public JSONUtil getFarmingDetailsByFarmId(String farmId, Integer pageNum, Integer pageSize) {
        pageNum=(pageNum-1)*pageSize;
        return new JSONUtil().setData(agrinfoCloudMapper.
                getFarmingDetailsByFarmId(farmId,pageNum,pageSize)).
                setCountSum(agrinfoCloudMapper.getFarmingDetailsByFarmIdCount(farmId));
    }
}
